<template>
  <div>
<h2>注册</h2>
<table class="table table-bordered">
        <tr>
          <td align="right">手机号</td>
          <td><input type="text" v-model="state.phone" ></td>
        </tr>
        <tr>
          <td align="right">密码</td>
          <td><input type="password" v-model="state.pwd"/></td>
        </tr>
       
        <tr>
          <td align="right">真实姓名</td>
          <td><input type="text" v-model="state.name"/></td>
        </tr>
        
        <tr>
          <td align="right">证件号码</td>
          <td><input type="text" v-model="state.cardCode" /></td>
        </tr>
       
        <tr>
          <td align="right"></td>
          <td>
              <input type="button" value="注册" @click="register">
          </td>
        </tr>
      </table>
  </div>
</template>

<script setup lang="ts">
import { reactive,toRefs } from 'vue';
import axios from 'axios';
import { useRoute } from 'vue-router';
 const router=useRoute()

 let data=reactive({
  state:{
    phone:'',
    pwd:'',
    name:'',
    cardCode:''
  },
  
 })
 let {state}=toRefs(data)

 function register()
 {
  let obj={
    "phone": state.value.phone,
  "pwd": state.value.pwd,
  "name":state.value.name,
  "card": state.value.cardCode
  }
  axios({
    url:'/api/Member/MemAdd',
    method:'post',
    data:obj

  })
  .then(res=>{
    if(res.data.data==1)
  {
    alert("注册成功")
   
  }
  else
  {
    alert("注册失败")
  }
  })
  .catch(err=>{

  })
 }
</script>

<style scoped>

</style>